package com.learning.jquizenglish.network;

import com.learning.jquizenglish.JQuizAppConfig;
import com.learning.jquizenglish.model.JQuizRequestModel;

/**
 * The Class JQuizEnglishApi.
 */
public class JQuizEnglishApi {

	/** The Constant BASE_URL. */
	public static final String BASE_URL = "http://flappybridmmo.com/quiz/home/";
	
	/**
	 * Gets the request question.
	 *
	 * @param questionType the question type
	 * @param level the level
	 * @param limit the limit
	 * @return the request question
	 */
	public static JQuizRequestModel getRequestQuestion(QuestionType questionType,Level level,int limit){
		int appType = AppType.GRAMMAR.getValue();
		if(JQuizAppConfig.IS_LISTENING_APP){
			appType = AppType.LISTENING.getValue();
		}
		String url = BASE_URL+"questions?types_id="
				+ questionType.getValue()+"&type_quiz="
				+ appType+"&level_id="
				+ level.getValue()+"&limit="
				+ limit;
		JQuizRequestModel requestModel = new JQuizRequestModel();
		requestModel.url = url;
		return requestModel;
	}
	
	/**
	 * The Enum QuestionType.
	 */
	public enum QuestionType{
		
		/** The question. */
		QUESTION(1),
		
		/** The flashcard. */
		FLASHCARD(2);
		
		/** The value. */
		private final int value;

	    /**
    	 * Instantiates a new question type.
    	 *
    	 * @param value the value
    	 */
    	private QuestionType(int value) {
	        this.value = value;
	    }

	    /**
    	 * Gets the value.
    	 *
    	 * @return the value
    	 */
    	public int getValue() {
	        return value;
	    }
	}
	
	/**
	 * The Enum AppType.
	 */
	public enum AppType{
		
		/** The grammar. */
		GRAMMAR(0),
		
		/** The listening. */
		LISTENING(1);
		
		/** The value. */
		private final int value;

	    /**
    	 * Instantiates a new app type.
    	 *
    	 * @param value the value
    	 */
    	private AppType(int value) {
	        this.value = value;
	    }

	    /**
    	 * Gets the value.
    	 *
    	 * @return the value
    	 */
    	public int getValue() {
	        return value;
	    }
	}
	
	/**
	 * The Enum Level.
	 */
	public enum Level{
		
		/** The elementary. */
		ELEMENTARY(1),
		
		/** The intermediate. */
		INTERMEDIATE(2),
		
		/** The advanced. */
		ADVANCED(3);
		
		/** The value. */
		private final int value;

	    /**
    	 * Instantiates a new level.
    	 *
    	 * @param value the value
    	 */
    	private Level(int value) {
	        this.value = value;
	    }

	    /**
    	 * Gets the value.
    	 *
    	 * @return the value
    	 */
    	public int getValue() {
	        return value;
	    }
	}
}
